package com.example.function.integration.polymorphism;

public class PolymorphismDemo {
    public static void main(String[] args) {
        // 创建动物数组，存储不同类型的动物对象
        Animal[] animals = new Animal[2];
        animals[0] = new Dog();
        animals[1] = new Cat();

        // 遍历数组，调用makeSound方法，展示多态性
        for (Animal animal : animals) {
            animal.makeSound();
        }
    }
}
